package com.dark.cms.base.utils;

import java.util.Collection;
import java.util.Map;

/**
 * 验证类
 * 
 * @author Devil
 * 
 */
public class ValidateUtil {
	/**
	 *
	 * 验证是否为空
	 * @param value
	 * @return
	 */
	public static boolean isEmpty(Object value) {
		if (value == null) {
			return true;
		} else if (value instanceof String) {
			return isEmpty((String) value);
		} else if (value instanceof Collection) {
			return isEmpty((Collection) value);
		} else if (value instanceof Map) {
			if (((Map) value).size() == 0) {
				return true;
			}
		}
		return false;
	}

	/** Check whether string s is empty. */
	public static boolean isEmpty(String s) {
		return ((s == null) || (s.trim().length() == 0) || "null".equals(s.trim().toLowerCase()));
	}

	/** Check whether collection c is empty. */
	public static boolean isEmpty(Collection c) {
		return ((c == null) || (c.size() == 0));
	}

	/** Check whether string s is NOT empty. */
	public static boolean isNotEmpty(String s) {
		return ((s != null) && (s.length() > 0));
	}

	/** Check whether collection c is NOT empty. */
	public static boolean isNotEmpty(Collection c) {
		return ((c != null) && (c.size() > 0));
	}

	public static boolean isString(Object obj) {
		return ((obj != null) && (obj instanceof String));
	}
}
